package com.example.fea;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private TextView mtvInfo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main1);

         mtvInfo = findViewById(R.id.tv_info);
         Button mBtnTwo = findViewById(R.id.btn_two);
         Button mBtnThree = findViewById(R.id.btn_three);
         Button mBtnFour = findViewById(R.id.btn_four);

         mBtnThree.setOnClickListener(this);
         mBtnFour.setOnClickListener(this);
         mBtnTwo.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 mtvInfo.setText("按钮2被点击了");
             }
         });

    }


   public void buttonOneClick(View view){
       mtvInfo.setText("按钮1被点击了");
   }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_three:{
                mtvInfo.setText("按钮3被点击了");
                break;
            }
            case R.id.btn_four:{
                mtvInfo.setText("按钮4被点击了");
                break;
            }
        }
    }
}